package flc.ast.adapter;


import android.view.View;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import flc.ast.R;
import flc.ast.bean.NoteBean;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;
import stark.common.basic.adaptermutil.StkSingleSpanProvider;

public class NoteAdapter extends StkProviderMultiAdapter<NoteBean> {


    public NoteAdapter() {
        addItemProvider(new StkSingleSpanProvider(126));
        addItemProvider(new NoteProvider());
    }

    private boolean isEdit;

    public void setEdit(boolean edit) {
        isEdit = edit;
    }

    private class NoteProvider extends BaseItemProvider<NoteBean> {
        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_note;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, NoteBean bean) {
            baseViewHolder.setText(R.id.tvNoteItemDate, bean.getDate());
            baseViewHolder.setText(R.id.tvNoteItemTitle, bean.getTitle());
            baseViewHolder.setText(R.id.tvNoteItemContent, bean.getContent());
            if (isEdit) {
                baseViewHolder.getView(R.id.ivNoteItemDelete).setVisibility(View.VISIBLE);
            } else {
                baseViewHolder.getView(R.id.ivNoteItemDelete).setVisibility(View.INVISIBLE);
            }
        }
    }

}
